﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;

namespace EffectEd
{
    public static class DataFiles
    {
        /// <summary>
        /// Returns the absolute path for an EffectEd datafile.
        /// </summary>
        /// <param name="subPath">file and optional subpath within data folder</param>
        /// <returns></returns>
        public static string GetAbsolutePath(string subPath)
        {
            return Path.Combine(PathUtils.GetAbsolutePath("data"), subPath);
        }

        /// <summary>
        /// Returns the content of a file or, if file not found, throws an exception.
        /// </summary>
        /// <param name="subPath">file and optional subpath within data folder</param>
        /// <returns></returns>
        public static string GetContent(string subPath)
        {
            var fullPath = GetAbsolutePath(subPath);
            if (!File.Exists(fullPath))
            {
                throw new FileNotFoundException(string.Format("Data file \"{0}\" could not be found.", subPath));
            }
            return File.ReadAllText(fullPath);
        }

    }
}
